# import time
#
#
# def cal_time(fn):
#     def inner(x):
#         start = time.time()
#         s = fn(x)
#         end = time.time()
#         return s,end-start
#
#     return inner
#
#
# @cal_time
# def sum_num(n):
#     x = 0
#     for i in range(1, n):
#         x += i
#     return x


#m = sum_num(10000)
#此时sum_num是 inner函数 8传给x 通过inner
# x传给n最后返回fn结果
#---------------
#print(m)
#m是元组
import time


def cal_time(fn):
    def inner(x,*args,**kwargs):#*args可以接收多个位置参数，多余数据以
        start = time.time()     #元组形式存储多余数据以元组形式存储

        s = fn(x)               #**kwargs可接受多个关键字参数，多余数据
        end = time.time()       #以字典形式保存因为关键字参数本来就是
        return s,end-start      #x=。。 y=。。的形式

    return inner


@cal_time
def sum_num(n):
    x = 0
    for i in range(1, n):
        x += i
    return x
m=sum_num(10000,'good',t='world')